﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Smart.MembershipService;
using Smart.UI.BaseClasses;

namespace Smart.Account
{
    public partial class RegisterUser : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            User newUser = new User();
            
            newUser.Email = tbEmail.Text;
            newUser.Password = tbPassword.Text;
            newUser.FirstName = tbFirstName.Text;
            newUser.LastName = tbLastName.Text;
            newUser.Phone = tbPhone.Text;

            newUser = Global.MembershipService.RegisterUser(newUser);

            if (newUser.UserId > 0)
            {
                string displayName = String.Format("{0} {1}", newUser.FirstName, newUser.LastName);
                Login(newUser.UserId, displayName);
            }
        }
    }
}